//
//  HomeRetweetedCell.swift
//  weiboLQ
//
//  Created by 半缘君 on 15/12/13.
//  Copyright © 2015年 banyuanjun.cn. All rights reserved.
//

import UIKit
let HomeRetweetedCellID = "HomeRetweetedCell"
class HomeRetweetedCell: HomeTableViewCell {
   override var viewModel:StatusViewModel? {
        didSet {
            
//            statusPicture.viewModel = viewModel
            retweetedLabel.text = viewModel?.textForRetweetedLable
            
            statusPicture.snp_updateConstraints { (make) -> Void in
                //                make.size.equalTo(statusPicture.bounds.size)
//                make.width.equalTo(statusPicture.bounds.width)
//                make.height.equalTo(statusPicture.bounds.height)
                let offset = (viewModel?.thumbnail_pics?.count > 0) ? LQHomeCellMargin : 0
                    make.top.equalTo(retweetedLabel.snp_bottom).offset(offset)
                
            }

        }
    }
    
///懒加载控件
    ///转发正文
    lazy var retweetedLabel:UILabel = UILabel(txt: "转发微博",alignment: NSTextAlignment.Left)
    ///转发微博背景按钮
    var backButton:UIButton = {
       let btn = UIButton()
        btn.backgroundColor = UIColor(white: 0.95, alpha: 1.0)
        return btn
    }()
    /// 配图
//    var statusPicture = StatusPictureView()
    
    /// - MARK: 构造函数
//    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
//
//        super.init(style:style, reuseIdentifier: reuseIdentifier)
//        setupUI()
//    }
//
//    required init?(coder aDecoder: NSCoder) {
//        fatalError("init(coder:) has not been implemented")
//    }

}

extension HomeRetweetedCell {
    
    override func setupUI() {
        super.setupUI()
        addBackButton()
        addRetweetedLabel()
        setStatusPictureView()
        
    }
    
    ///添加背景按钮
    private func addBackButton () {
        contentView.insertSubview(backButton, belowSubview: statusPicture)
        backButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(centerLabel.snp_bottom)//.offset(LQHomeCellMargin)
            make.left.equalTo(contentView)
            make.right.equalTo(contentView)
            make.bottom.equalTo(bottomView.snp_top)
            
        }
    }
    ///添加转发微博的文本
    private func addRetweetedLabel () {
        
        contentView.insertSubview(retweetedLabel, belowSubview: statusPicture)
        retweetedLabel.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(backButton).offset(LQHomeCellMargin)
            make.left.equalTo(centerLabel)//.offset(LQHomeCellMargin)
        }
 }
    
    /// 添加pictureView
    private func setStatusPictureView () {
//        statusPicture.backgroundColor = UIColor.redColor()
        statusPicture.snp_makeConstraints { (make) -> Void in
        make.top.equalTo(retweetedLabel.snp_bottom)//.offset(LQHomeCellMargin)
        make.left.equalTo(retweetedLabel)//.offset(LQHomeCellMargin)
//            make.width.equalTo(300)
//            make.height.equalTo(90)
        }
    }
}
